<!DOCTYPE html>
<html>
<head>
    <include file="Public/head"/>
</head>
<body>

<div class="ui-wrap">

    <!--s msg-head-->
    <div class="ui-msg-head">
        <p>互动评论</p>
    </div><!--e msg-head-->

    <!--s banner-2-->
    <div class="swiper-container swiper-container-2" style="margin-top: 0px;">
        <div class="swiper-wrapper">
            <div class="swiper-slide">
                <a href="http://m.jiabangougo.com/home.html">
                	<img src="__IMG__/Home/banner-02-1.jpg"/>
            	</a>
            </div>
            <div class="swiper-slide">
                <a href="javascript:;">
                	<img src="__IMG__/Home/banner-02-2.jpg"/>
            	</a>
            </div>
            <div class="swiper-slide">
                <a href="http://www.bd-tou.com/wap/index.php?ctl=deal&act=show&id=79#">
                	<img src="__IMG__/Home/banner-02-3.jpg"/>
            	</a>
            </div>
            <div class="swiper-slide">
                <a href="javascript:;">
                	<img src="__IMG__/Home/banner-02-4.jpg"/>
            	</a>
            </div>
        </div>
    </div><!--e banner-2-->

    <!--s msg-list-head-->
    <div class="ui-msg-list-head">
        <span>共{$count}条评论</span>
        <a href="javascript:;" id="warp_show"><span>说两句</span></a>
    </div><!--e msg-list-head-->

    <!--s msg-release-->
    <div class="ui-msg-release-wrap ">
        <div class="ui-msg-release">
            <div class="ui-msg-release-hd">
                <p>说点什么</p>
            </div>
            <div class="ui-msg-release-cnt">
                <textarea id="comment" name="" rows="" cols=""></textarea>
            </div>
            <div class="ui-msg-release-btn">
                <a href="javascript:;" id="cancel">取消</a>
                <a href="javascript:;" id="submit">发布</a>
            </div>
        </div>
    </div>
    <!--e msg-release-->

    <!--s msg-list-->
    <ul class="ui-msg-list">
        <volist name="list" id="vo">
            <li>
                <div class="ui-msg-icon">
                    <img src="{$vo.user_img}" height="50" width="50"/>
                </div>
                <div class="ui-msg-wrap">
                    <div class="ui-user-info">
                        <p>{$vo.user_name}</p>
                        <small>{$vo.create_time|time_format='Y-m-d'}</small>
                    </div>
                    <div class="ui-msg-info">
                        <p>{$vo.comment_id}楼：{$vo.content}</p>
                    </div>
                </div>
            </li>
        </volist>
    </ul><!--e msg-list-->
    <script type="text/javascript">
    
    	var mySwiper = new Swiper('.swiper-container-2',{speed:500,pagination : '.swiper-pagination-2',autoplay : 3000});

        $(function(){
            page = 10;
            chek = 1;
            var mySwiper = new Swiper('.ui-wrap',{
                onTouchEnd: function(swiper){
                    if ($(document).scrollTop() >= $(document).height() - $(window).height()){
                        if(chek == 1){
                            ajaxRulset();
                            chek = 0;
                        }
                    }
                }
            });
            /* 动态加载数据 */
            function ajaxRulset(){
                $.ajax({
                    url:"{:U('Forum/ajaxRulset')}",
                    type:'post',
                    data:{page:page},
                    success:function(result){
                        result= $.parseJSON(result);
                        if(result.length>=1){
                            $.each( result , function (i,item) {
                                $("<li>"+
                                "<div class='ui-msg-icon'>"+
                                "<img src='"+item.user_img+"' height='50' width='50'/>"+
                                "</div>"+
                                "<div class='ui-msg-wrap'>"+
                                "<div class='ui-user-info'>"+
                                "<p>"+item.user_name+"</p>"+
                                "<small>"+item.create_time+"</small>"+
                                "</div>"+
                                "<div class='ui-msg-info'>"+
                                "<p>"+item.comment_id+"楼："+item.content+"</p>"+
                                "</div>"+
                                "</div>"+
                                "</li>").appendTo('.ui-msg-list');
                            });
                            page+=Number(result.length);
                        }else{
                            item = result;
                            $("<li>"+
                            "<div class='ui-msg-icon'>"+
                            "<img src='"+item.user_img+"' height='50' width='50'/>"+
                            "</div>"+
                            "<div class='ui-msg-wrap'>"+
                            "<div class='ui-user-info'>"+
                            "<p>"+item.user_name+"</p>"+
                            "<small>"+item.create_time+"</small>"+
                            "</div>"+
                            "<div class='ui-msg-info'>"+
                            "<p>"+item.comment_id+"楼："+item.content+"</p>"+
                            "</div>"+
                            "</div>"+
                            "</li>").appendTo('.ui-msg-list');
                        }
                        chek = 1;
                    }
                });
            }
        });

        $('#warp_show').click(function(){
            $('.ui-msg-release-wrap').addClass('show');
        });
        $('#cancel').click(function(){
            $('.ui-msg-release-wrap').removeClass('show');
        });
        $('#submit').click(function(){
            content = $('#comment').val();
            if(content == null){
                alert('内容不能为空');
            }
            $('.ui-msg-release-wrap').removeClass('show');
            $.ajax({
                url:"{:U('Forum/save')}",
                type:"POST",
                data:{content:content},
                success:function(result){
                    if(result.status==1){
                        alert('评论成功');
                        item = result;
                        $("<li>"+
                        "<div class='ui-msg-icon'>"+
                        "<img src='"+item.user_img+"' height='50' width='50'/>"+
                        "</div>"+
                        "<div class='ui-msg-wrap'>"+
                        "<div class='ui-user-info'>"+
                        "<p>"+item.user_name+"</p>"+
                        "<small>"+item.create_time+"</small>"+
                        "</div>"+
                        "<div class='ui-msg-info'>"+
                        "<p>"+item.comment_id+"楼："+item.content+"</p>"+
                        "</div>"+
                        "</div>"+
                        "</li>").before('.ui-msg-list');
                    }else{
                        alert('评论失败');
                    }
                }
            });
        });
    </script>
</div>
</body>
</html>
